package com.smart.proxy;

public class MethodPerformace {
    private long begin;
    private long end;
    private String serviceMethod;

    public MethodPerformace(String serviceMethod) {
        reset(serviceMethod);
    }

    public void printPerformace() {
        // 获取目标方法执行完成之后的时间
        end = System.currentTimeMillis();
        long elapse = end - begin;
        // 报告目标方法的执行时间
        System.out.println(serviceMethod + "花费" + elapse + "毫秒。");
    }

    public void reset(String serviceMethod) {
        this.serviceMethod = serviceMethod;
        // 记录目标类方法开始执行点的系统时间
        this.begin = System.currentTimeMillis();
    }
}
